class Solution {
public:
    long long maxScore(vector<int>& a, vector<int>& b) {
        int n = a.size(), m = b.size();
        vector<vector<long long>> dp(m + 1, vector<long long> (n + 1, 0));

        for(int i = 1; i < 5; ++i )
            dp[0][i] = LLONG_MIN >> 1;
        for(int i = 1 ; i <= m; ++i)
        {
            for(int j = 1; j <= n; ++j)
            {
                long long x = dp[i - 1][j];
                long long y = dp[i - 1][j - 1] + (long long)a[j - 1] * b[i - 1];
                dp[i][j] = max(x, y);
            }
        }
        return dp[m][n];
    }
};
